Gloomy-Networking Documentation

Connection

These scripts are used to establish, disconnect, or get information about established connections.


gnet_connect

Syntax:

gnet_connect(IP, Port);
Argument name Type Description
IP String The IP address to attempt to connect to
Port Number The port to connect to

Returns: (Array) Result Returns a 2 element array where index[0] is null if we were unable to send a connection request, and index[1] is a String that is a message containing information about the result

Description:

Attempt to make a connection to the given ip and port.

Example:

// Example showing how a connection result can be used
_result		  = gnet_connect("127.0.0.1", "3000");
_connectionId = _result[0];					// Assigned connection id to reference this connection
_resultMsg    = _result[1];					// String message of the result

if (_result == null) { Connection attempt not started. resultMsg will tell you why! }
else { connection attempt started, waiting on reply! }

gnet_get_connection_by_id

Syntax:

gnet_get_connection_by_id(Identifier);
Argument name Type Description
Identifier Number of the connection to attempt to find the instance of

Returns: (InstanceId) Connection Returns the instance id of the connection associated with the provided id, or null if the connection was not found

Description:

Returns a connection object associated with the given connectionId


gnet_disconnect_self

Syntax:

gnet_disconnect_self();

Description:

Disconnect self, clears Network Manager data structures


gnet_get_username

Syntax:

gnet_get_username(ConnectionId);
Argument name Type Description
ConnectionId number The identifier of the connection to get the username of.

Returns: (String) Username Returns the username of the connection id or null if the connection was not found

Description:

Get the username associated with a connection.